<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>startOf() | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>startOf()</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>startOf()</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/manipulating/start-of/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/03-manipulating/03-start-of.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment().startOf(String);
</code></pre>

							</div>
<p>&#x901A;&#x8FC7;&#x5C06;&#x539F;&#x59CB;&#x7684; moment &#x8BBE;&#x7F6E;&#x4E3A;&#x65F6;&#x95F4;&#x5355;&#x4F4D;&#x7684;&#x5F00;&#x5934;&#x6765;&#x5BF9;&#x5176;&#x8FDB;&#x884C;&#x66F4;&#x6539;&#x3002;</p>
<pre><code class="language-javascript">moment().startOf(&apos;year&apos;);    // &#x8BBE;&#x7F6E;&#x4E3A;&#x4ECA;&#x5E74;&#x4E00;&#x6708;1&#x65E5;&#x4E0A;&#x5348; 12:00
moment().startOf(&apos;month&apos;);   // &#x8BBE;&#x7F6E;&#x4E3A;&#x672C;&#x6708;1&#x65E5;&#x4E0A;&#x5348; 12:00
moment().startOf(&apos;quarter&apos;);  // &#x8BBE;&#x7F6E;&#x4E3A;&#x5F53;&#x524D;&#x5B63;&#x5EA6;&#x7684;&#x5F00;&#x59CB;&#xFF0C;&#x5373;&#x6BCF;&#x6708;&#x7684;&#x7B2C;&#x4E00;&#x5929;&#x4E0A;&#x5348; 12:00
moment().startOf(&apos;week&apos;);    // &#x8BBE;&#x7F6E;&#x4E3A;&#x672C;&#x5468;&#x7684;&#x7B2C;&#x4E00;&#x5929;&#x4E0A;&#x5348; 12:00
moment().startOf(&apos;isoWeek&apos;); // &#x6839;&#x636E; ISO 8601 &#x8BBE;&#x7F6E;&#x4E3A;&#x672C;&#x5468;&#x7684;&#x7B2C;&#x4E00;&#x5929;&#x4E0A;&#x5348; 12:00
moment().startOf(&apos;day&apos;);     // &#x8BBE;&#x7F6E;&#x4E3A;&#x4ECA;&#x5929;&#x4E0A;&#x5348; 12:00
moment().startOf(&apos;date&apos;);     // &#x8BBE;&#x7F6E;&#x4E3A;&#x4ECA;&#x5929;&#x4E0A;&#x5348; 12:00
moment().startOf(&apos;hour&apos;);    // &#x8BBE;&#x7F6E;&#x4E3A;&#x5F53;&#x524D;&#x65F6;&#x95F4;&#xFF0C;&#x4F46;&#x662F; 0 &#x5206;&#x949F;&#x3001;0 &#x79D2;&#x949F;&#x3001;0 &#x6BEB;&#x79D2;
moment().startOf(&apos;minute&apos;);  // &#x8BBE;&#x7F6E;&#x4E3A;&#x5F53;&#x524D;&#x65F6;&#x95F4;&#xFF0C;&#x4F46;&#x662F; 0 &#x79D2;&#x949F;&#x3001;0 &#x6BEB;&#x79D2;
moment().startOf(&apos;second&apos;);  // &#x4E0E; moment().milliseconds(0); &#x76F8;&#x540C;
</code></pre>
<p>&#x8FD9;&#x4E9B;&#x5FEB;&#x6377;&#x65B9;&#x5F0F;&#x4E0E;&#x4EE5;&#x4E0B;&#x7684;&#x57FA;&#x672C;&#x76F8;&#x540C;&#x3002;</p>
<pre><code class="language-javascript">moment().startOf(&apos;year&apos;);
moment().month(0).date(1).hours(0).minutes(0).seconds(0).milliseconds(0);
</code></pre>
<pre><code class="language-javascript">moment().startOf(&apos;hour&apos;);
moment().minutes(0).seconds(0).milliseconds(0)
</code></pre>
<p>&#x4ECE; <strong>2.0.0</strong> &#x7248;&#x672C;&#x5F00;&#x59CB;&#xFF0C;<code>moment#startOf(&apos;day&apos;)</code> &#x66FF;&#x4EE3; <code>moment#sod</code>&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF1A;<code>moment#startOf(&apos;week&apos;)</code> &#x65B0;&#x589E;&#x4E8E; <strong>2.0.0</strong> &#x7248;&#x672C;&#x3002;</p>
<p>&#x4ECE; <strong>2.1.0</strong> &#x7248;&#x672C;&#x5F00;&#x59CB;&#xFF0C;<code>moment#startOf(&apos;week&apos;)</code> &#x4F7F;&#x7528;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x654F;&#x611F;&#x7684;&#x661F;&#x671F;&#x5F00;&#x59CB;&#x65E5;&#x671F;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF1A;<code>moment#startOf(&apos;isoWeek&apos;)</code> &#x65B0;&#x589E;&#x4E8E; <strong>2.2.0</strong> &#x7248;&#x672C;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF1A;<code>moment#startOf(&apos;date&apos;)</code> &#x4F5C;&#x4E3A; day &#x7684;&#x522B;&#x540D;&#x65B0;&#x589E;&#x4E8E; <strong>2.13.0</strong>&#x3002;</p>
					</div>
          <div id="content_right">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment().startOf(String);
</code></pre>

							</div>
<p>Mutates the original moment by setting it to the start of a unit of time.</p>
<pre><code class="language-javascript">moment().startOf(&apos;year&apos;);    // set to January 1st, 12:00 am this year
moment().startOf(&apos;month&apos;);   // set to the first of this month, 12:00 am
moment().startOf(&apos;quarter&apos;);  // set to the beginning of the current quarter, 1st day of months, 12:00 am
moment().startOf(&apos;week&apos;);    // set to the first day of this week, 12:00 am
moment().startOf(&apos;isoWeek&apos;); // set to the first day of this week according to ISO 8601, 12:00 am
moment().startOf(&apos;day&apos;);     // set to 12:00 am today
moment().startOf(&apos;date&apos;);     // set to 12:00 am today
moment().startOf(&apos;hour&apos;);    // set to now, but with 0 mins, 0 secs, and 0 ms
moment().startOf(&apos;minute&apos;);  // set to now, but with 0 seconds and 0 milliseconds
moment().startOf(&apos;second&apos;);  // same as moment().milliseconds(0);
</code></pre>
<p>These shortcuts are essentially the same as the following.</p>
<pre><code class="language-javascript">moment().startOf(&apos;year&apos;);
moment().month(0).date(1).hours(0).minutes(0).seconds(0).milliseconds(0);
</code></pre>
<pre><code class="language-javascript">moment().startOf(&apos;hour&apos;);
moment().minutes(0).seconds(0).milliseconds(0)
</code></pre>
<p>As of version <strong>2.0.0</strong>, <code>moment#startOf(&apos;day&apos;)</code> replaced <code>moment#sod</code>.</p>
<p><strong>Note:</strong> <code>moment#startOf(&apos;week&apos;)</code> was added in version <strong>2.0.0</strong>.</p>
<p>As of version <strong>2.1.0</strong>, <code>moment#startOf(&apos;week&apos;)</code> uses the locale aware week start day.</p>
<p><strong>Note:</strong> <code>moment#startOf(&apos;isoWeek&apos;)</code> was added in version <strong>2.2.0</strong>.</p>
<p><strong>Note:</strong> <code>moment#startOf(&apos;date&apos;)</code> was added as an alias for day in <strong>2.13.0</strong></p>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>